from django.contrib import admin

from models import Project, Task, Risk, Issue, Status

# Register your models here.

class TaskAdmin(admin.ModelAdmin):
    list_display = (
        'title',
        'project',
        'status',
        'start',
        'end',
    )
    ordering = ['start']
    list_filter = ['start', 'status']

class TaskInline(admin.TabularInline):
    model = Task
    extra=0

class RiskAdmin(admin.ModelAdmin):
    list_display = [
        'name',
        'project',
        'impact',
        'status',
    ]
    ordering = [
        'project',
        '-impact',
    ]
    list_filter = [
        'project',
        'status',
        'impact',
    ]

class RiskInline(admin.StackedInline):
    model = Risk
    extra=0


class IssueAdmin(admin.ModelAdmin):
    list_display = (
        'name',
        'project',
        'severity',
        'status',
    )
    ordering = ['project', '-severity']
    list_filter = ['project', 'status']

class IssueInline(admin.StackedInline):
    model = Issue
    extra=0


class StatusAdmin(admin.ModelAdmin):
    list_display = (
        'date',
        'project',
        'cost',
        'time',
        'quality',
    )
    ordering = ['project','date']
    list_filter = ['project', 'cost', 'time', 'quality']

class StatusInline(admin.TabularInline):
    model = Status
    extra=0

class ProjectAdmin(admin.ModelAdmin):
    list_display = (
        'name',
    )

    inlines = [
        StatusInline,
        RiskInline,
        IssueInline,
        TaskInline,
    ]


admin.site.register(Task, TaskAdmin)
admin.site.register(Risk, RiskAdmin)
admin.site.register(Issue, IssueAdmin)
admin.site.register(Status, StatusAdmin)
admin.site.register(Project, ProjectAdmin)
